import os

import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource


def generate_launch_description():
    bringup_dir = get_package_share_directory('turn_on_bichon')
    launch_dir = os.path.join(bringup_dir, 'launch')

    bichon_robot = IncludeLaunchDescription(
            PythonLaunchDescriptionSource(os.path.join(launch_dir, 'turn_on_bichon.launch.py')),
    )
    lidar = IncludeLaunchDescription(
            PythonLaunchDescriptionSource(os.path.join(launch_dir, 'bichon_lidar.launch.py')),
    )
    return LaunchDescription([
        bichon_robot,
        lidar,
        launch_ros.actions.Node(
            parameters=[
                get_package_share_directory("slam_toolbox") + '/config/mapper_params_online_async.yaml'
            ],
            package='slam_toolbox',
            executable='async_slam_toolbox_node',
            name='slam_toolbox',
            output='screen',
            remappings=[('odom','odom_combined')]
        )
    ])
